package com.bosssoft.mapper;



import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bosssoft.entity.dto.FibDepartmentDTO;
import com.bosssoft.entity.po.FibAccountPO;
import com.bosssoft.entity.po.FibDepartmentPO;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * 部门表(FibDepartment)表数据库访问层
 *
 * @author makejava
 * @since 2021-08-20 10:59:11
 */
@Mapper
public interface FibDepartmentMapper extends BaseMapper<FibDepartmentPO> {

    @Select("select dept_id,dept_code,dept_name," +
            "dept_address as deptAddress,dept_phone as deptPhone,dept_contact as deptContact," +
            "dept_parent_id as deptParentId,dept_auth_num as deptAuthNum," +
            "dept_area as deptArea,dept_car_num as deptCarNum,dept_lift_num as deptLiftNum,dept_eqp_num as deptEqpNum," +
            "dept_pub_bgt as deptPubBgt,dept_spec_funds as deptSpecFunds,dept_gov_funds,create_time as createTime,update_time as updateTime," +
            "create_by as createBy,update_by as updateBy,deleted as deleted,version as version " +
            "from fib_department limit #{offset},#{limit}")
    List<FibDepartmentPO> selectAll(Long offset,Long limit);
    @Delete("delete from fib_department where dept_id = #{deptId}")
    boolean delete(FibDepartmentPO fibDepartmentPO);
    /**
     * 修改数据
     *
     * @return 影响行数
     */
    @Update("update fib_department set \n" +
            "dept_id = #{deptId},dept_code = #{deptCode},dept_name = #{deptName}," +
            "dept_address = #{deptAddress},dept_phone = #{deptPhone},dept_contact = #{deptContact}," +
            "dept_parent_id = #{deptParentId},dept_auth_num = #{deptAuthNum}," +
            "dept_area = #{deptArea},dept_car_num = #{deptCarNum},dept_lift_num = #{deptLiftNum},dept_eqp_num = #{deptEqpNum}," +
            "dept_pub_bgt = #{deptPubBgt},dept_spec_funds = #{deptSpecFunds},dept_gov_funds = #{deptGovFunds},update_time = now()," +
            "update_by = #{updateBy},deleted = #{deleted},version = version + 1 " +
            "where dept_id = #{deptId}")
    boolean update(FibDepartmentPO fibDepartmentPO);
    @Update("update fib_department set \n" +
            "deleted = #{deleted},update_time = now(),update_by = #{updateBy},version = version + 1 \n" +
            "where dept_id = #{deptId}")
    boolean updateDeleted(FibDepartmentPO fibDepartmentPO);

    @Select("select dept_id \n " +
            "from fib_department \n " +
            "where dept_parent_id= #{deptId}")
    List<Long> selectChildrenIds(Long deptId);
}

